﻿@model PhoneBilling.Models.SliceDetailMgtModel
@{
    ViewBag.Title = "分段计费管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="slice_detail_mgt">
@if (Model.Message != null){<h2>@Model.Message</h2>}
<script type="text/javascript">
    function changeSlice() {
        window.location.href = "/Manage/SliceDetailMgt/" + $("#sliceList").val();
    }
    function del(id, name) {
        var r = confirm("确认删除分段吗？");
        if (r == true) {
            window.location.href = "/Manage/SliceDetailDelete?sliceID=" + id+"&name="+name;
        }
        return false;
    }
</script>
<div class="system_input_contain">
    <label for>当前收费等级表：</label>
    @Html.DropDownListFor(m => m.CurrentSlice, new SelectList(Model.SliceList, "ID", "Name"), new { id = "sliceList", style = "input-text", onchange = "changeSlice()" }) 
    <input type="button" id="btnNewSliceDetail" value="新增分段计费表明细" />
    
</div>  
@{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.AppendLine(string.Format("var data={{Total:{0},", Model.SliceDetailList.Count));
    sb.AppendLine("Rows:[");
    for (int i = 0; i < Model.SliceDetailList.Count; i++)
    {
        var item = Model.SliceDetailList[i];
        if(i == 0)
        {
            sb.Append("{");
        }
        else
        {
            sb.Append(",{");
        }
        sb.Append(string.Format("分段起点时间:'{0}',", item.分段起点时间));
        sb.Append(string.Format("分段截止时间:'{0}',", item.分段截止时间));
        sb.Append(string.Format("费率:'{0}',", item.费率));
        sb.Append(string.Format("费用类别:'{0}',", item.费用类别));
        sb.Append(string.Format("计次单位:'{0}',", item.计次单位));
        sb.Append(string.Format("是否计算计次:'{0}',", item.是否计算计次));
        sb.Append(string.Format("名称:'{0}'", item.名称));
        sb.Append("}");
    }
    sb.AppendLine("]};");
    string data = sb.ToString();
}
<script type="text/javascript">
    @Html.Raw(data)
    
    var menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '新增', click: newclick },
            { line: true },
            { text: '修改', click: modifyclick },
            { line: true },
            { text: '删除', click: deleteclick }
            ]
        });
    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '分段起点时间', name: '分段起点时间',width:100},
                { display: '分段截止时间', name: '分段截止时间',width:100},
                { display: '费率', name: '费率',width:80},
                { display: '费用类别', name: '费用类别',width:80},
                { display: '计次单位', name: '计次单位',width:100},
                { display: '是否计算计次', name: '是否计算计次',width:120},
                { display: '名称', name: '名称',width:120}
                ],
                isScroll: false, data: data,pageSize:30,alternatingRow:true,  
                onContextmenu: function (node, e) {
            actionNodeID = node;
            menu.show({ top: e.pageY, left: e.pageX });
            return false;
        }
        }
        );resetGridHeight(grid);
        $(window).resize(function () {
                resetGridHeight(grid);
            });
    });    function newclick(item, i) {
        var path = "/Manage/SliceDetailEdit?sliceID=@Model.CurrentSlice";
        window.location.href=path;
    }
    function modifyclick(item, i) {
        var path = "/Manage/SliceDetailEdit?sliceID=@Model.CurrentSlice&name="+actionNodeID.data.名称;
        window.location.href=path;
    }    function deleteclick(item, i) {
        del('@Model.CurrentSlice',actionNodeID.data.名称);
    }
    $(document).ready(function () {
        $("#btnNewSliceDetail").ligerButton(
        {
            click: function () {
                window.location.href = "/Manage/SliceEdit";
            },width:160
        });
        $("#btnNew").ligerButton(
        {
            click: function () {
                window.location.href = "/Manage/SliceDetailEdit?sliceID=@Model.CurrentSlice";
            }
        });
        $("#btnModify").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    var path = "/Manage/SliceDetailEdit?sliceID=@Model.CurrentSlice&name="+row.名称;
                    window.location.href=path;
                }
            }
        });

        $("#btnDelete").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    del('@Model.CurrentSlice',row.名称);
                }
            }
        });
    });
</script>

<div class="system_toolbar">
    <input type="button" id="btnNew" value="新增" />
    <input type="button" id="btnModify" value="修改" />
    <input type="button" id="btnDelete" value="删除" />
</div>
<div id="maingrid"></div>
</div>